import time

import pymysql

con = pymysql.connect(host='192.168.1.243',
                      user='radius',
                      password='123456',
                      db='radius',
                      port=3306,
                      charset='utf8')
try:
    with con.cursor() as cursor:
        cursor.execute("insert into test(gttime) values('%s')"%time.ctime(time.time()))
        con.commit()
except:
    con.rollback()
finally:
    con.close()
